$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        params: {
            type: null,
            userIds: null
        },
        dom: {
            confirm: null
        },
        form: null,
        init: function () {
            this.params.type    = xhTool.getQuery('type');
            this.params.userIds = xhTool.getQuery('userIds');
            this.dom.confirm    = window.top.xhTop.getModalConfirmDom();

            this.form = new xhForm($('#form_group'));

            this.listener();
        },
        listener: function () {
            var $this = this;
            //确认分配角色
            $this.dom.confirm.click(function() {
                $this.funObj().submitGroup();
            });
        },
        funObj: function(){
            var $this = this;
            return {
                submitGroup: function() {
                    $this.form.submit(baseUrl + 'Group/saveUserGroup', {type: $this.params.type, userIds: $this.params.userIds}, function(result){
                        xhExtra.setBtnNormal($this.dom.confirm);
                        if (xhExtra.checkError(result)) return false;
                        window.top.xhTop.showSuccess(result.msg);
                        window.top.xhTop.closeModal();
                    });
                }
            }
        }
    }
}